#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <cstring>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <string>
#include "comm.h"
using namespace std;

int main()
{
    int wfd = open(FILENAME, O_WRONLY);
    if(wfd < 0)
    {
        cerr << "errno:" << errno << ",errstring:" << strerror(errno) << endl;
        return 1;
    }
        while(true)
        {
        string message;
        getline(cin, message);
        ssize_t s = write(wfd, message.c_str(), message.size());
        if(s < 0)
        {
            cerr << "errno:" << errno << ",errstring:" << strerror(errno) << endl;
            return 2;
        }
    }
    return 0;
}